import request from '@/utils/request'

/**
 * 获取会话列表
 * @returns {Promise} 会话列表
 */
export function getConversationList() {
  return request.get('/im/conversation/list');
}

/**
 * 标记所有会话为已读
 * @returns {Promise} 操作结果
 */
export function readAllConversations() {
  return request.put('/im/conversation/read-all');
}

/**
 * 清空指定会话的未读消息数
 * @param {Number} targetId - 目标用户ID
 * @param {Number} targetType - 目标类型，1-单聊，2-群聊
 * @returns {Promise} 操作结果
 */
export function clearConversationUnreadCount(targetId, targetType) {
  return request.put(`/im/conversation/read?targetId=${targetId}&targetType=${targetType}`);
}

/**
 * 删除会话
 * @param {Object} data - 会话信息
 * @param {Number} data.targetId - 目标用户ID
 * @param {Number} data.targetType - 目标类型，1-单聊，2-群聊
 * @returns {Promise} 操作结果
 */
export function deleteConversation(data) {
  return request.delete('/im/conversation/delete', data);
}

/**
 * 设置会话置顶状态
 * @param {Number} targetId - 目标用户ID
 * @param {Number} targetType - 目标类型，1-单聊，2-群聊
 * @param {Boolean} isTop - 是否置顶
 * @returns {Promise} 操作结果
 */
export function setConversationTop(targetId, targetType, isTop) {
  return request.post(`/im/conversation/top?targetId=${targetId}&targetType=${targetType}&isTop=${isTop}`);
}

/**
 * 设置会话免打扰状态
 * @param {Number} targetId - 目标用户ID
 * @param {Number} targetType - 目标类型，1-单聊，2-群聊
 * @param {Boolean} isMuted - 是否免打扰
 * @returns {Promise} 操作结果
 */
export function setConversationMute(targetId, targetType, isMuted) {
  return request.post(`/im/conversation/mute?targetId=${targetId}&targetType=${targetType}&isMuted=${isMuted}`);
} 